package com.godyao.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 封装Handler方法相关信息
 * @author godyao
 */
public class Handler {
    /**
     * handler方法的拥有对象
     */
    private Object controllerObj;

    private Method method;

    private Pattern urlPattern;

    /**
     * 记录方法形参的参数顺序 参数名：index
     */
    private Map<String, Integer> paramIndexMapping;

    public Handler(Object controllerObj, Method method, Pattern urlPattern) {
        this.controllerObj = controllerObj;
        this.method = method;
        this.urlPattern = urlPattern;
        this.paramIndexMapping = new HashMap<>();
    }

    public Object getControllerObj() {
        return controllerObj;
    }

    public void setControllerObj(Object controllerObj) {
        this.controllerObj = controllerObj;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getUrlPattern() {
        return urlPattern;
    }

    public void setUrlPattern(Pattern urlPattern) {
        this.urlPattern = urlPattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
